/////////////////////////////////////////////////////
// add_ruler.sqf
// by Nou 
//
// Execute this script in a units init line to add additional functionality to the map.
//
// Features:
//      1. 3000 meter ruler that extends 1500 meters from the center and displays the ruler 
//         heading in degrees, mil64, mil60.
//      2. Compass that can be placed anywhere on the screen.
//
// Editor Usage:
//      nul = [this] execVM "script\add_ruler.sqf";
//
// Player Usage:
//      Hold the keys below and the click on the map to execute their functionality.
//
//      H Key: Place the origin of the ruler, this is signified with a green dot. Clicking again
//             will clear the origin, and the ruler from the screen.
//      J Key: Clicking while holding this key draws the ruler at the angle from the origin.
//      K Key: Place a compass at this point, the center of the compass rose will be where you click.
//      L Key: Clear the compass on click.
//
// Issues:
//      The main issues right now are issues of locality. This script is intended to only work on the
//      units it is executed on. I have not figured out how to do this in multiplayer. Currently this
//      functionality is added to all players that are present when the script is executed. Players 
//      that join in progress will not have it added to them unless it inits in the unit they are 
//      joining. Any help would be appreciated in solving this issue.
//
/////////////////////////////////////////////////////
sleep 5;

if (isDedicated) exitWith {
	
};

nouKeyBoardHandler = compile preprocessFile "map_no_sat\script\ruler_kb_handler.sqf";
nouRulerHandler = compile preprocessFile "map_no_sat\script\ruler.sqf";

player setVariable ["Nou_Map_Line_Number", 0];
player setVariable ["Nou_Map_Line_Segment_Start", [0, 0, 0]];
player setVariable ["Nou_Map_Line_Color", 0];


((findDisplay 12) displayCtrl 51) ctrlSetEventHandler ["MouseButtonClick", "[player, _this] call nouRulerHandler"];
/*
((findDisplay 12) displayCtrl 51) ctrlSetEventHandler ["MouseButtonClick", "[player, _this] execVM ""script\ruler.sqf"";"];
*/
((findDisplay 12) displayCtrl 51) ctrlSetEventHandler ["keyDown", "[player, _this, true] call nouKeyBoardHandler"];
((findDisplay 12) displayCtrl 51) ctrlSetEventHandler ["keyUp", "[player, _this, false] call nouKeyBoardHandler"];